package tr.edu.ege.kipler.satisfiability.completion.rules;

import tr.edu.ege.kipler.satisfiability.ReasonerException;
import tr.edu.ege.kipler.satisfiability.container.ABox;
import tr.edu.ege.kipler.satisfiability.container.World;
import tr.edu.ege.kipler.satisfiability.container.WorldConstraintSystem;
import tr.edu.ege.kipler.satisfiability.container.operational.IndividualNameManager;
import tr.edu.ege.kipler.syntax.atomicformula.ConceptAssertion;
import tr.edu.ege.kipler.syntax.concept.ConceptName;

/**
 * 
 * @author İnanç Seylan
 *
 */
public class EmptyDomainRule extends CompletionRule {
	boolean applied;

	public EmptyDomainRule() {
		super();
	}

	public EmptyDomainRule(WorldConstraintSystem wcs, World world) {
		super(wcs, world);
	}

	@Override
	public void apply() throws ReasonerException {
		applied = false;
		ABox abox = getWorld().getABox();
		if (!abox.individualIterator().hasNext()) {
			ConceptAssertion ca = new ConceptAssertion(ConceptName.topConcept(),
					IndividualNameManager.getInstance()
							.generateIndividualName());
			abox.add(ca);
			getWcs().getData().getLogger().info(
					"WCS " + getWcs().getId() + " Empty domain rule: Adding "
							+ ca);
			applied = true;
		}
	}

	@Override
	public boolean isApplied() {
		return applied;
	}

}
